import pytest,time,openpyxl
from selenium import webdriver
from Base.Base2 import Base2

@pytest.fixture
def driver():
    driver = webdriver.Edge()
    driver.maximize_window()
    yield driver
    time.sleep(3)
    driver.quit()

def test_A3mall(driver):
    work = openpyxl.load_workbook('gjz.xlsx')
    excel = work['Sheet1']
    base2 = Base2(driver)

    for row in excel.iter_rows(min_row=2,values_only=True):
        action = row[2]
        params = {}
        if action == 'open_url':
            params['url'] = row[5]
        elif action in ['send_keys','click']:
            params['loc'] = [row[3],row[4]]
            print(row[3])
            print(row[4])
            if action == 'send_keys':
                params['info'] = row[5]
        elif action == 'sleep':
            params['timeout'] = row[5]

        method = getattr(base2,str(action))
        method(**params)